//
// Created by 215609 on 2024/8/7.
//

#ifndef TSAVPLAYER_AVPLAYER_H
#define TSAVPLAYER_AVPLAYER_H
#define JAVA_PLAYER_EVENT_CALLBACK_API_NAME "playerEventCallback"

#include "BasePlayer.h"
#include "VideoDecoder.h"
#include "AudioDecoder.h"
#include "AAudioRender.h"
#include "OpenSLRender.h"
#include "OboeRender.h"
#include "NativeWindowRender.h"
#include "OboeRender.h"
class AVPlayer : public BasePlayer{

protected:
    VideoDecoder *videoDecoder;
    AudioDecoder *audioDecoder;
    OpenSLRender *m_OpenSLRender;
    OboeRender *m_OboeRender;
    AAudioRender *m_AAudioRender;

    VideoRender *m_VideoRender = nullptr;

    virtual ~AVPlayer();
    void Play() override;
    JNIEnv * GetJNIEnv(bool *isAttach) override;
    virtual void UnInit() override;
    JavaVM * GetJavaVM() override;
    jobject GetJavaObj();
    virtual void Stop();
public:
    virtual void init(JNIEnv *jniEnv, jobject obj,char *url, int renderType, jobject surface);
    static void PostMessage(void *context, int msgType, float msgCode);
    JavaVM *m_JavaVM = nullptr;
    jobject m_JavaObj = nullptr;

    AVPlayer();
};


#endif //TSAVPLAYER_AVPLAYER_H
